package com.apress.javaee6.chapter03;

import javax.persistence.Embeddable;

@Embeddable
public class NewsId {
	private String title;
	private String language;
	
	public NewsId(){
		super();
	}
	
	public NewsId(String title,String language){
		this.title=title;
		this.language = language;
	}
	
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getLanguage() {
		return language;
	}
	public void setLanguage(String language) {
		this.language = language;
	}
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return (this.getTitle()+this.getLanguage()).hashCode();
	}
	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		boolean result;
		NewsId newsObj=(NewsId)obj;
		if(!(obj instanceof NewsId))
			return false;
		if(this.getTitle().equals(newsObj.getTitle()) &&
				this.getLanguage().equals(newsObj.getLanguage())){ 
			result=true;
		}else{
			result=false;
		}
		return result;
	}
	
	
}
